Create your own interactive experiment from scratch
In this step, you'll create your own experiment folder and build your first interactive experiment based on your Step 0 research. This is where you transition from following examples to building your own psychology research tool.
First, test that your deployment works with our Rock-Paper-Scissors example. This confirms your setup is working correctly before you build your own experiment.
Choose your move to test logging:
<button onclick="logChoice('Rock')">🗿 Rock</button>
When clicked, this calls the logChoice('Rock') function with 'Rock' as the parameter.
function logChoice(choice) {
const trialData = {
timestamp: new Date().toISOString(),
choice: choice,
trial: trialCount++
};
console.log('✅ Trial:', trialData);
}
This function creates a data object with timestamp and choice, then logs it to the console.
In your main project directory (same level as "Mock Project"), create your own experiment folder:
index.htmlexperiment.js for your JavaScript codeyour-project-folder/
├── Mock Project/ (our examples)
├── Your Project Name/
│ ├── index.html (your experiment)
│ └── experiment.js (your code)
├── styles.css
└── index.html (main homepage)
Create your index.html file with this basic structure, adapted for your experiment:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Your Experiment Name</title>
<link rel="stylesheet" href="../styles.css">
</head>
<body>
<div class="container">
<h1>Your Experiment Title</h1>
<p>Brief description of what participants will do</p>
<!-- Your experiment buttons/inputs here -->
<button onclick="logResponse('Option1')">First Choice</button>
<button onclick="logResponse('Option2')">Second Choice</button>
<div id="status">Ready</div>
</div>
<script src="experiment.js"></script>
</body>
</html>
Create your experiment.js file with basic data logging:
let experimentData = [];
let trialCount = 0;
function logResponse(response) {
trialCount++;
const trialData = {
trial: trialCount,
timestamp: new Date().toISOString(),
response: response,
// Add other data you want to track
};
experimentData.push(trialData);
console.log('✅ New Trial:', trialData);
console.log('📊 All Data:', experimentData);
// Update page feedback
document.getElementById('status').innerHTML =
`Trial ${trialCount}: Recorded '${response}'`;
}
Customize the template based on your Step 0 study design:
Once your experiment is working, add it to the main homepage:
index.html file in your project root<!-- and --> comment tagsFor your new link to work on your public GitHub Pages site, you need to "commit" and "push" your changes. This saves a new version of your project and updates the live website.
Method 1: Using the Cursor/VS Code GUI (Recommended)
Method 2: Using Git Commands in the Terminal
Open the terminal (in Cursor: `Terminal > New Terminal`) and run these commands one by one:
git add .This stages all your changes for the next commit.
git commit -m "Add my experiment to homepage"This saves your changes with a descriptive message.
git pushThis uploads your saved changes to GitHub, updating your live site.
Before using the prompt below, you need to prepare the context for the AI:
study-plan.md file that you created in Step 0 in context by @-mentioning it.Once you've done that, copy the following prompt to generate your experiment code:
Based on my Step 0 research planning, help me create my first interactive experiment:
Please create:
Keep it simple for Step 3 - just basic interaction and console logging. I'll add data storage and analysis in later steps.
../styles.css)